package com.esri.core.internal.tasks.ags.a;

import com.esri.core.internal.io.handler.h;
import com.esri.core.internal.tasks.TaskListener;
import com.esri.core.internal.tasks.d;
import com.esri.core.io.UserCredentials;
import com.esri.core.tasks.ags.find.FindResult;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class a extends d<List<FindResult>> {
    private static final long serialVersionUID = 1;

    public a(b bVar, String str, UserCredentials userCredentials, TaskListener<List<FindResult>> taskListener) {
        super(bVar, str, userCredentials, taskListener);
    }

    public a(b bVar, String str, UserCredentials userCredentials) {
        super(bVar, str, userCredentials);
    }

    @Override // com.esri.core.internal.tasks.a
    /* renamed from: a */
    public List<FindResult> execute() throws Exception {
        JsonParser jsonParser = null;
        try {
            jsonParser = h.b(getServiceURL() + "/find", this.actionInput.generateRequestParams(), getServiceCredentials());
            return a(jsonParser);
        } finally {
            if (jsonParser != null) {
                jsonParser.close();
            }
        }
    }

    private List<FindResult> a(JsonParser jsonParser) throws Exception {
        ArrayList arrayList = null;
        if (com.esri.core.internal.util.d.c(jsonParser)) {
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if ("results".equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            if (arrayList == null) {
                                arrayList = new ArrayList();
                            }
                            arrayList.add(FindResult.fromJson(jsonParser));
                        }
                    }
                } else {
                    jsonParser.skipChildren();
                }
            }
            return arrayList;
        }
        return null;
    }
}
